import 'package:flutter/cupertino.dart';

// 邮票样式
class StampClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    const double circleRadius = 5; // 圆形凹槽半径
    const double spacing = 5; // 圆形凹槽间距
    final path = Path();
    // 从左上角开始
    path.moveTo(0, 0);
    // 绘制顶部直线
    path.lineTo(size.width, 0);
    // 绘制右侧锯齿（圆形凹槽）
    for (double y = 0; y < size.height; y += circleRadius * 2 + spacing) {
      path.lineTo(size.width, y + spacing);
      path.arcToPoint(
        Offset(size.width, y + spacing + circleRadius * 2),
        radius: const Radius.circular(circleRadius),
        clockwise: false, // 圆弧向内绘制
      );
    }

    // 绘制底部直线
    path.lineTo(0, size.height);

    // 绘制左侧锯齿（圆形凹槽）
    for (double y = size.height; y > 0; y -= circleRadius * 2 + spacing) {
      path.lineTo(0, y - spacing);
      path.arcToPoint(
        Offset(0, y - spacing - circleRadius * 2),
        radius: const Radius.circular(circleRadius),
        clockwise: false, // 圆弧向内绘制
      );
    }

    // 闭合路径回到顶部
    path.lineTo(0, 0);
    path.close();

    return path;
  }

  @override
  bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
